<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改紧急联系人')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body>
<div class="main-content">
    <form id="form-emergency-edit" class="form-horizontal" AUTOCOMPLETE="OFF">
        <input name="id" type="hidden" id="id" th:value="${emergency.ID}"/>
        <h4 class="form-header h4">紧急联系人</h4>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">联系人姓名：</label>
                    <div class="col-sm-8">
                        <input name="EmergencyName" id="EmergencyName"th:value="${emergency.EmergencyName}" class="form-control" type="text"/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">联系人关系：</label>
                    <div class="col-sm-8">
                        <select name="Relation" id="Relation" class="form-control m-b"
                                th:with="type=${@dict.getType('eCD_Relation')}">
                            <option value="">请选择</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:selected="${emergency.Relation+'' == dict.dictValue}"
                                    th:value="${dict.dictValue}"></option>
                        </select></div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">联系电话：</label>
                    <div class="col-sm-8">
                        <input name="Telephone" id="Telephone"th:value="${emergency.Telephone}"  class="form-control" type="text"/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">联系地址：</label>
                    <div class="col-sm-8">
                        <input name="address" id="address"th:value="${emergency.address}"   class="form-control laydate-demo-1" type="text"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">电子邮件：</label>
                    <div class="col-sm-8">
                        <input name="email" id="email"th:value="${emergency.email}"  class="form-control" type="text"/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">邮编：</label>
                    <div class="col-sm-8">
                        <input name="PostCode" id="PostCode" th:value="${emergency.PostCode}"class="form-control" type="text"/>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>


<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: datetimepicker-js"/>

<script th:inline="javascript">

    var prefix = ctx + "entryManage/EntryBackground";

    $(function () {

        layui.use('laydate', function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: '.laydate-demo-1',
                type: 'date'
            });
        });
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-emergency-edit").serializeArray();
            var id = $("#id").val();
            var EmergencyName = $("#EmergencyName").val();
            var Relation = $("#Relation").val();
            var Telephone = $("#Telephone").val();
            var address = $("#address").val();
            var email = $("#email").val();
            var PostCode = $("#PostCode").val();

            data.push({"name": "id", "value": id});
            data.push({"name": "EmergencyName", "value": EmergencyName});
            data.push({"name": "Relation", "value": Relation});
            data.push({"name": "Telephone", "value": Telephone});
            data.push({"name": "address", "value": address});
            data.push({"name": "email", "value": email});
            data.push({"name": "PostCode", "value": PostCode});
            $.operate.save(prefix + "/editEmergency", data);

        }
    }


</script>
</body>
</html>
